package com.sdhs.qualitymanage.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * ManageTreeSelect树结构实体类
 *
 * @author ww
 */
@Setter
@Getter
public class QualityTreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private Long id;

    /**
     * 节点名称
     */
    private String label;

    /**
     * 详细数据
     */
    private GcQualityManagement data;

    /**
     * 节点禁用
     */
    private boolean disabled = false;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<QualityTreeSelect> children;

    public QualityTreeSelect() {
    }

    public QualityTreeSelect(GcQualityManagement manage) {
        this.id = manage.getId();
        this.label = manage.getDocumentType();
        this.data = manage;
        this.children = manage.getChildren().stream().map(QualityTreeSelect::new).collect(Collectors.toList());
    }

}
